package com.android.examplelist;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;

import org.apache.http.Header;

public class NewsEntity{

	public static void getData(String URL, final AsyncHttpClientActivity activity) {
		AsyncHttpClient client = new AsyncHttpClient(); 
		
		client.setTimeout(1000);
		
		
        client.get(URL, new AsyncHttpResponseHandler() {  
              
            @Override  
            public void onStart() {  
                super.onStart();  
                System.out.println("onStart");  
                
                activity.onStart1();
            }  
              
            @Override  
            public void onFinish() {  
                super.onFinish();  
                System.out.println("onFinish");  
                
                activity.onFinish1();
            }

			@Override
			public void onFailure(int arg0, Header[] arg1, byte[] arg2,
					Throwable arg3) {
				
				System.out.println(arg3);  
				
				System.out.println("onFailure");  
				// TODO Auto-generated method stub
                //asyncHttpButton.setText("失败"); 
				activity.onFailure1();
			}

			
			@Override
			public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
				// TODO Auto-generated method stub
				String html = new String(arg2);
				//System.out.println(html);
				System.out.println("onSuccess");  
				//asyncHttpButton.setText("成功"); 
				activity.onSuccess1(html);
			}  
		
        });
	}
}
